//公共
import myHeader from "/pages/headerfoot/pages/header.vue"
// 图标
import uIcons from "/uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
//语言
import Lang from '@/utils/lang.js';
//公共底部
import Tabbar from "@/pages/headerfoot/pages/benefitfooter.vue";
//公共公益方法
import commonBenefit from '@/common/commonbenefit.js';
//公共方法
import Base from '@/common/base.js';
//骨架
import uniSkeleton from "/plugin/skeleton/components/heaven-skeleton/heaven-skeleton.vue";
//微信api
import weChat from '@/lib/wechat.js';
//cache缓存
import Cache from '@/utils/cache.js';


export default {
	components: {
		uIcons,
		myHeader,
		Tabbar,
		uniSkeleton,
	},
	data() {
		return {
			mentalarithmetic: Lang.lang.mentalarithmetic,
			loading: true,
			projectlist: [], //列表
			url: commonBenefit.automaticurl('projectexercises'),
			page: 1,
			langs: Lang.lang,
			subjectid: '',
		}
	},

	onShow() {
		var that = this;
		that.ifreglogin();
	},
	onLoad(option) {
		var that = this;
		that.subjectid = option.subjectid;
		that.getdata();
	},
	methods: {
		//开始训练
		startTraining() {
			var that = this;
			uni.reLaunch({
				url: commonBenefit.automaticurl('projectexercisestwo') + '?projectid=' + that.subjectid,
			})

		},
		getdata() {
			//得到项目列表1
			var that = this;
			var data = {};
			data['subject_id'] = that.subjectid;
			commonBenefit.getSubjectApiMethod(data).then(res => {
				if (res) {
					that.loading = false;
					that.projectlist = res.content.split("|");
				}
			});
		},
		//判断是否需要注册或者登录与其他
		async ifreglogin() {
			var that = this;
			//注册
			await Base.globalauthorization();

			//判断学生是否注册
			await commonBenefit.ifStudenter().then(res => {
				if (res) {
					uni.redirectTo({
						url: commonBenefit.automaticurl('studentreg')
					})
				}
			});
		},
	}
}